package com.dsdl.chatapp.data.source;

import android.support.annotation.NonNull;

import com.dsdl.chatapp.data.SocketMessage;

/**
 * Created by zzg on 2016/8/27.
 * 数据层处理
 */
public class ChatRepository implements ChatDataSource {
    private static ChatRepository INSTANCE;
    private final ChatDataSource mChatLocalDataSource;
    //==================================================
    //先预留出来远程操作的接口实现，以后扩展功能可以用
    //==================================================
    private final ChatDataSource mChatRemoteDataSource;

    private ChatRepository(@NonNull ChatDataSource chatLocalDataSource, @NonNull ChatDataSource chatRemoteDataSource){
        mChatLocalDataSource = chatLocalDataSource;
        mChatRemoteDataSource = chatRemoteDataSource;
    }

    public static ChatRepository getInstance(ChatDataSource chatLocalDataSource,ChatDataSource chatRemoteDataSource){
        if (INSTANCE ==  null){
            INSTANCE =  new ChatRepository(chatLocalDataSource,chatRemoteDataSource);
        }
        return INSTANCE;
    }

    @Override
    public void saveMsg(@NonNull SocketMessage chatMsg) {
        mChatLocalDataSource.saveMsg(chatMsg);
    }

    @Override
    public void deleteMsg(@NonNull SocketMessage chatMsg) {
        mChatLocalDataSource.deleteMsg(chatMsg);
    }

    @Override
    public void deleteAllMsg(String userId) {
        mChatLocalDataSource.deleteAllMsg(userId);
    }

    @Override
    public void loadOffLineMsg(String userId) {

    }
}
